var commonjs = require("@rollup/plugin-commonjs");
var baoShuang = require("./build/baoShuang");
var woAiZhuiJu = require("./build/woAiZhuiJu");
var fanQieXiaoShuo = require("./build/fanQieXiaoShuo");
var fanQieChangTing = require("./build/fanQieChangTing");
var fanQieChangTingYinYue = require("./build/fanQieChangTingYinYue");
var touTiao = require("./build/touTiao");
var shanDianSouSuo = require("./build/shanDianSouSuo");
var youShi = require("./build/youShi");
var xiGua = require("./build/xiGua");
var kuaiShouJiSu = require("./build/kuaiShouJiSu");
var baiDuJiSu = require("./build/baiDuJiSu");
var baiDuChangTing = require("./build/baiDuChangTing");
var defaultConfig = {
  format: "iife",
  strict: false,
};
var test = {
  files: [
    // prettier-ignore
    "novelReadTest",
    "ocrTest",
    "startAppTest",
    "test",
  ],
  dir: "test",
};

var commonConfig = {
  watch: {
    include: "src/**",
  },
  plugins: [commonjs()],
};

var baseDir = "./src/tests";
var newBaseDir = "./src/apps";
var testBaseDir = "./src/test";
var mainBaseDir = "./src";
var outputBaseDir = "./src/bundle";
var newApps = [
  // prettier-ignore
  fanQieXiaoShuo,
  fanQieChangTing,
  fanQieChangTingYinYue,
  touTiao,
  shanDianSouSuo,
  youShi,
  xiGua,
  kuaiShouJiSu,
  baiDuChangTing,
  baiDuJiSu,
  baoShuang,
  woAiZhuiJu,
];
var tests = [test];
var newAppRollupConfig = [];
newApps.forEach((app) => {
  app.files.forEach((file) => {
    newAppRollupConfig.push({
      input: `${newBaseDir}/${app.dir}/${file}.js`,
      output: {
        file: `${outputBaseDir}/${app.dir}/b-${file}.js`,
        name: `${file}`,
        ...defaultConfig,
      },
      ...commonConfig,
    });
  });
});
var testRollupConfig = [];
tests.forEach((app) => {
  app.files.forEach((file) => {
    testRollupConfig.push({
      input: `${testBaseDir}/${file}.js`,
      output: {
        file: `${outputBaseDir}/${app.dir}/bundle-${file}.js`,
        name: `${file}`,
        ...defaultConfig,
      },
      ...commonConfig,
    });
  });
});

module.exports = [
  ...newAppRollupConfig,
  ...testRollupConfig,
];
